cmake_minimum_required(VERSION 3.10)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
include_directories(${TASKBUS_INTERFACEDIR})
set(PRJ_SOURCES
	main.cpp
	function_info.cpp
)

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
	include_directories(${TASKBUS_THIRDIR}/win32/fftw)
	if(TB64BIT)
	link_directories(${TASKBUS_THIRDIR}/win32/fftw/x64)
	set (FFT_LIB fftw3-3)
	else()
	link_directories(${TASKBUS_THIRDIR}/win32/fftw/x32)
	set (FFT_LIB fftw3-3)
	endif()
else()
	set (FFT_LIB fftw3)
endif()
#############Target======================

add_executable(transform_fft
	${PRJ_SOURCES}
)
target_link_libraries(transform_fft
	${FFT_LIB}
	Qt${QT_VERSION_MAJOR}::Core
	${TBLinkExtra}
)

# ====copy doc
add_custom_command(TARGET transform_fft
		 POST_BUILD
		 COMMAND echo Copy Handbook to EXE path
		 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/readme.md ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/transform_fft.md
	 )

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
 if(TB64BIT)
 add_custom_command(TARGET transform_fft
		  PRE_BUILD
		  COMMAND echo Copy FFTW to EXE path
		  COMMAND ${CMAKE_COMMAND} -E copy ${TASKBUS_THIRDIR}/win32/fftw/x64/libfftw3-3.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
	  )
 else()
 add_custom_command(TARGET transform_fft
		  PRE_BUILD
		  COMMAND echo Copy FFTW to EXE path
		  COMMAND ${CMAKE_COMMAND} -E copy ${TASKBUS_THIRDIR}/win32/fftw/x86/libfftw3-3.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
	  )
 endif()
endif()
